package com.zjsd.sqeybusiness.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.zjsd.sqeybusiness.domain.ApplySample;
import com.zjsd.sqeybusiness.service.IApplySampleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 申请样品Controller
 *
 * @author Zheng
 * @date 2020-11-05
 */
@RestController
@RequestMapping("/jph/applySample")
public class ApplySampleController extends BaseController
{
    @Autowired
    private IApplySampleService applySampleService;

    /**
     * 查询申请样品列表
     */
    @PreAuthorize("@ss.hasPermi('jph:applySample:list')")
    @GetMapping("/list")
    public TableDataInfo list(ApplySample applySample)
    {
        startPage();
        List<ApplySample> list = applySampleService.selectApplySampleList(applySample);
        return getDataTable(list);
    }

    /**
     * 导出申请样品列表
     */
    @PreAuthorize("@ss.hasPermi('jph:applySample:export')")
    //@Log(title = "申请样品", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ApplySample applySample)
    {
        List<ApplySample> list = applySampleService.selectApplySampleList(applySample);
        ExcelUtil<ApplySample> util = new ExcelUtil<ApplySample>(ApplySample.class);
        return util.exportExcel(list, "applySample");
    }

    /**
     * 获取申请样品详细信息
     */
    @PreAuthorize("@ss.hasPermi('jph:applySample:query')")
    @GetMapping(value = "/{applyId}")
    public AjaxResult getInfo(@PathVariable("applyId") Long applyId)
    {
        return AjaxResult.success(applySampleService.selectApplySampleById(applyId));
    }

    /**
     * 新增申请样品
     */
    @PreAuthorize("@ss.hasPermi('jph:applySample:add')")
    //@Log(title = "申请样品", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ApplySample applySample)
    {
        return toAjax(applySampleService.insertApplySample(applySample));
    }

    /**
     * 修改申请样品
     */
    @PreAuthorize("@ss.hasPermi('jph:applySample:edit')")
    //@Log(title = "申请样品", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ApplySample applySample)
    {
        return toAjax(applySampleService.updateApplySample(applySample));
    }

    /**
     * 删除申请样品
     */
    @PreAuthorize("@ss.hasPermi('jph:applySample:remove')")
    //@Log(title = "申请样品", businessType = BusinessType.DELETE)
	@DeleteMapping("/{applyIds}")
    public AjaxResult remove(@PathVariable Long[] applyIds)
    {
        return toAjax(applySampleService.deleteApplySampleByIds(applyIds));
    }
}
